#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int getFrequency(char word[], char ch);

int main(void){
    
	FILE *inptr, *outptr;
	
	inptr = fopen("input.txt", "r");
	if(inptr == NULL){
		printf("Error in opening input.txt\n");
		exit(1);
	}
	outptr = fopen("output.txt", "w");
	
	char ch, word[30];
	int count;
	
		printf ("Enter character to search: \n");
        	scanf ("%c" , &ch);
        		fprintf (outptr , " word		         freqency of %c\n" , ch);
        		
	    while (fscanf (inptr , "%s" , word) != EOF) {
	        
	       	count = getFrequency( word , ch );
	       	
 	fprintf (outptr , "%-30s %d\n" , word , count);
	
	}
	
	fclose (outptr);
	fclose (inptr);
	
	return 0; }
	
	
int getFrequency(char word[], char ch) {
	
int i , count = 0;

for(i = 0; k < strlen(word); i++){

if (word[i] == ch)
count ++ ;}	
	
return count;	
}



